import React, { useCallback, useState } from 'react'

export default function CallbackHookDemo01() {

  const [count, setCount] = useState(0)

  const increment1 = () => {
    console.log('run increment')
    setCount(count + 1)
  }

  const increment2 = useCallback(
    () => {
      console.log('run increment')
      setCount(count + 1)
    }, [count]
  )

  return (
    <div>
      <h2>CallbackHookDemo01</h2>
      <h2>Currnet Count: {count}</h2>
      <button onClick={increment1}>+1</button>
      <button onClick={increment2}>+1</button>
    </div>
  )
}
